package org.adultedu.service.serviceimpl;
import org.adultedu.dao.UserMapper;
import org.adultedu.pojo.User;
import org.adultedu.service.UserService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Transactional
@Service("UserServiceImpl")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    public User querytUser(User user) {
        return userMapper.querytUser(user);
    }

    public List<User> queryAllUser() {
        return userMapper.queryAllUser();
    }

    public User queryUserById(int id) {
        return userMapper.queryUserById(id);
    }


    public List queryAdmin(String username) {
        return userMapper.queryAdmin(username);
    }


    public int insertAdmin(String id, String username, String password, Integer roleid) {
        return userMapper.insertAdmin(id,username,password,roleid);
    }

    @Override
    public int insertRole(String id, Integer roleid) {
        return userMapper.insertRole(id,roleid);
    }

    @Override
    public int updateAdmin(String id, String username, String password, Integer state, String reason, String other) {
        return userMapper.updateAdmin(id,username,password,state,reason,other);
    }


    public int updateRole(String id, Integer roleid) {
        return userMapper.updateRole(id,roleid);
    }
    public int deleteAdmin(String id) {
        return userMapper.deleteAdmin(id);
    }

    public User queryUserByUsername(String username) {
        return userMapper.queryUserByUsername(username);
    }

    public Map UserLogin(String username){
        return userMapper.UserLogin(username);
    }

    public int updateUserPwdById(int id) {
        return userMapper.updateUserPwdById(id);
    }

    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }

    public int insertUserRole(User user){return userMapper.insertUserRole(user);}
}
